#include <iostream>
#include<algorithm>
#include <string.h>
#include<fstream>
#include<time.h>
#include<stack>
#include<vector>
#include<sstream>
using namespace std;
int dp[2010][2010] = { 0 };
int main()
{
	string s1, s2;
	while(cin >> s1 >> s2)
	{
		int size1 = s1.size();
		int size2 = s2.size();
		for (int i = 1; i <= size1; i++)
		{
			dp[i][0] = i;
		}
		for (int j = 1; j <= size2; j++)
		{
			dp[0][j] = j;
		}
		for (int i = 1; i <= size1; i++)
		{
			
			for (int j = 1; j <= size2; j++)
			{
				if (s1[i-1] == s2[j-1])
					dp[i][j] = dp[i - 1][j - 1];
				else
				{
					dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
				}
			}
		}
		cout << dp[size1][size2] << endl;
	}
	return 0;
}